package advanced.io;

import java.io.*;

public class L_BufferedReader {
    public static void main(String[] args) {

    }

    /**
     * 高效缓冲读取流
     */
    public static void bufferReader(File src) {
        String line = null;
        try (BufferedReader reader = new BufferedReader(new FileReader(src))) {
            while ((line = reader.readLine()) != null) {
                System.out.println(line);

            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }

    /**
     * 高效缓冲写出流
     */
    public static void bufferWriter(File dest, String msg) {
        try (Writer writer = new BufferedWriter(new FileWriter(dest))) {
            writer.write(msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
